package com.ruoyi.ftrl.controller;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;  
import com.ruoyi.ftrl.domain.RealTimeData;
import com.ruoyi.ftrl.service.IRealTimeDataService;
import org.springframework.beans.factory.annotation.Autowired;  
import org.springframework.web.bind.annotation.*;  

import java.util.List;  

@RestController  
@RequestMapping("/realTimeData")  
public class RealTimeDataController extends BaseController {  

    @Autowired  
    private IRealTimeDataService realTimeDataService;  

    // 查询所有数据  
    @GetMapping("/list")  
    public AjaxResult list() {  
        List<RealTimeData> dataList = realTimeDataService.selectAllRealTimeData();  
        return AjaxResult.success(dataList);  
    }  

    // 根据 ID 查询数据  
    @GetMapping("/{id}")  
    public AjaxResult getInfo(@PathVariable Long id) {  
        RealTimeData realTimeData = realTimeDataService.selectRealTimeDataById(id);  
        return AjaxResult.success(realTimeData);  
    }  

    // 创建数据  
    @PostMapping  
    public AjaxResult add(@RequestBody RealTimeData realTimeData) {  
        int result = realTimeDataService.insertRealTimeData(realTimeData);  
        return toAjax(result);  
    }  

    // 更新数据  
    @PutMapping  
    public AjaxResult edit(@RequestBody RealTimeData realTimeData) {  
        int result = realTimeDataService.updateRealTimeData(realTimeData);  
        return toAjax(result);  
    }  

    // 删除数据  
    @DeleteMapping("/{id}")  
    public AjaxResult remove(@PathVariable Long id) {  
        int result = realTimeDataService.deleteRealTimeDataById(id);  
        return toAjax(result);  
    }  
}